Saving Movies
The Movie Toolbox provides a set of high-level functions for storing movies within files. These files have a file type of
'MooV'
and a resource type of
'moov'
. Your application can gain access to existing movies with either the
NewMovieFromFile
function or the
NewMovieFromDataFork
function (described on
NewMovieFromFile
and
NewMovieFromDataFork
, respectively). Once you have loaded the movie, your application uses the functions that are described in this section to save any changes you have made to the movie.
You can use the
AddMovieResource
function to add a new movie resource to a movie file. Your application can use this function to save a movie that it created using the functions described in
"Functions for Editing Movies,"
. You can use the
UpdateMovieResource
function to replace an existing movie resource in a movie file. You can remove a movie resource by calling the
RemoveMovieResource
function.
The movie resources that your application creates with the
AddMovieResource
and
UpdateMovieResource
functions may contain references to movie data. These references identify the data that constitute the movie. However, the movie data can be stored outside of the movie file. If you want to create a movie file that contains all of its movie data, use the
FlattenMovie
function. If you want to create a single-fork movie file, use the
FlattenMovieData
function.
The
PutMovieIntoHandle
function places a QuickTime movie into a handle. You can then convert the movie into specialized data formats.
The
HasMovieChanged
and
ClearMovieChanged
functions allow your application to work with the movie changed flag that is maintained by the Movie Toolbox. You can use this flag to determine whether a movie has been changed.
The movie changed flag indicates whether you have changed the movie. Such actions as editing the movie, adding samples to a media, or changing a data reference cause the flag to indicate that the movie has changed. There are several operations that the movie changed flag does not reflect, including changing the volume, rate, or time settings for the movie. These settings change frequently when a movie is played. Your application must monitor these settings itself.
The Movie Toolbox also supplies functions for storing and retrieving movies that are stored in the data fork of a file. These functions provide robust data reference resolution and improve low memory performance. The
NewMovieFromDataFork
function enables you to retrieve a movie that is stored anywhere in the data fork of a file. You can use the
PutMovieIntoDataFork
function to store an atom version of a specified movie in the data fork of a file.
HasMovieChanged
The
HasMovieChanged
function allows your application to determine whether a movie has changed and needs to be saved.
pascal Boolean HasMovieChanged (Movie theMovie);
-
theMovie
-
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
(described on
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
, respectively).
DESCRIPTION
The
HasMovieChanged
function returns a Boolean value that reflects the contents of the movie changed flag. The function sets the returned value to
true
if the movie has been changed in such a way that it should be saved. Otherwise, the returned value is set to
false
.
Your application can clear the movie changed flag, indicating that the movie has not changed, by calling the
ClearMovieChanged
function, which is described in the next section.
ERROR CODES
invalidMovie
|
-2010
|
This movie is corrupted or invalid
|
SEE ALSO
Both the
AddMovieResource
function (described on
AddMovieResource
) and the
UpdateMovieResource
function (described on
UpdateMovieResource
) update the movie file and clear the movie changed flag, indicating that the movie has not been changed.
ClearMovieChanged
The
ClearMovieChanged
function sets the movie changed flag to indicate that the movie has not been changed.
pascal void ClearMovieChanged (Movie theMovie);
-
theMovie
-
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
(described on
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
, respectively).
ERROR CODES
invalidMovie
|
-2010
|
This movie is corrupted or invalid
|
SEE ALSO
Your application can read the contents of the movie changed flag by calling the
HasMovieChanged
function, which is described in the previous section. Both the
AddMovieResource
and
UpdateMovieResource
functions also clear the movie changed flag.
AddMovieResource
The
AddMovieResource
function adds a movie resource to a specified resource file. Your application identifies the movie to be added to the movie file.
pascal OSErr AddMovieResource (Movie theMovie, short resRefNum,
short *resId,
ConstStr255Param resName);
-
theMovie
-
Specifies the movie you wish to add to the movie file. Your application obtains this movie identifier from such functions as
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
(described on
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
, respectively).
-
resRefNum
-
Identifies the movie file to which the resource is to be added. Your application obtains this value from the
OpenMovieFile
function, described on
OpenMovieFile
. The movie file specified by this parameter cannot be a single-fork movie file.
-
resId
-
Contains a pointer to a field that contains the resource ID number for the new resource. If the field referred to by the
resId
parameter is set to 0, the Movie Toolbox assigns a unique resource ID number to the new resource. The toolbox then returns the movie's resource ID number in the field referred to by the
resId
parameter. The
AddMovieResource
function assigns resource ID numbers sequentially, starting at 128. If the
resId
parameter is set to
nil
, the Movie Toolbox assigns a unique resource ID number to the new resource and does not return that resource's ID value.
-
resName
-
Points to a character string that contains the name of the movie resource. If you set the
resName
parameter to
nil
, the toolbox creates an unnamed resource.
DESCRIPTION
The
AddMovieResource
function adds the movie to the file, effectively saving any changes you have made to the movie. This function does not work with single-fork movie files.
After updating the movie file,
AddMovieResource
clears the movie changed flag, indicating that the movie has not been changed.
ERROR CODES
invalidMovie
|
-2010
|
This movie is corrupted or invalid
|
File Manager errors Memory Manager errors Resource Manager errors
UpdateMovieResource
The
UpdateMovieResource
function replaces the contents of a movie resource in a specified movie file. You specify the movie that is to be placed into the resource.
This function can accommodate single-fork movie files.
pascal OSErr UpdateMovieResource (Movie theMovie, short resRefNum,
short resId,
ConstStr255Param resName);
-
theMovie
-
Specifies the movie you wish to place in the movie file. Your application obtains this movie identifier from such functions as
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
(described on
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
, respectively).
-
resRefNum
-
Identifies the movie file that contains the resource to be changed. Your application obtains this value from the
OpenMovieFile
function, described on
OpenMovieFile
. If this parameter specifies a single-fork movie file using the
movieInDataForResID(-1)
constant, the Movie Toolbox places the movie resource into the file's data fork.
-
resId
-
Specifies the resource to be changed.
-
resName
-
Points to a new name for the resource. If you do not want to change the resource's name, set this parameter to
nil
.
DESCRIPTION
After updating the movie file, the
UpdateMovieResource
function clears the movie changed flag, indicating that the movie has not been changed.
ERROR CODES
invalidMovie
|
-2010
|
This movie is corrupted or invalid
|
File Manager errors Memory Manager errors Resource Manager errors
RemoveMovieResource
The
RemoveMovieResource
function removes a movie resource from a specified movie file.
pascal OSErr RemoveMovieResource (short resRefNum, short resId);
-
resRefNum
-
Identifies the movie file that contains the movie resource. Your application obtains this value from the
OpenMovieFile
function, described on
OpenMovieFile
.
-
resId
-
Specifies the resource to be removed.
ERROR CODES
File Manager errors Resource Manager errors
PutMovieIntoHandle
The
PutMovieIntoHandle
function creates a new movie resource for you. You can use this handle to store a QuickTime movie in a specialized storage format.
pascal OSErr PutMovieIntoHandle (Movie theMovie,
Handle publicMovie);
-
theMovie
-
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
(described on
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
, respectively).
-
publicMovie
-
Contains the handle that is to receive the new movie resource. The
PutMovieIntoHandle
function places the new movie resource into this handle. The function resizes the handle if necessary.
DESCRIPTION
Note that you cannot use this new movie with other Movie Toolbox functions, except for the
NewMovieFromHandle
function. You can use the
NewMovieFromHandle
function, described on
NewMovieFromHandle
, to load a movie from a handle.
SPECIAL CONSIDERATIONS
Movies saved using
PutMovieIntoHandle
contain less robust data references than those created using the
AddMovieResource
or
PutMovieIntoDataFork
functions (described on
AddMovieResource
and
PutMovieIntoDataFork
, respectively).
ERROR CODES
invalidMovie
|
-2010
|
This movie is corrupted or invalid
|
Memory Manager errors
FlattenMovie
The
FlattenMovie
function creates a new movie file containing a specified movie. This file also contains all the data for the movie--that is, the Movie Toolbox resolves any data references and includes the corresponding movie data in the new movie file.
pascal void FlattenMovie (Movie theMovie, long movieFlattenFlags,
const FSSpec *theFile,
OSType creator, ScriptCode scriptTag,
long createMovieFileFlags,
short *resId, ConstStr255Param resName);
-
theMovie
-
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
(described on
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
, respectively).
-
movieFlattenFlags
-
Controls the process of adding movie data to the new movie file. The following flags are available (be sure to set unused flags to 0):
-
flattenAddMovieToDataFork
-
Causes the movie to be placed in the data fork of the new movie file, as well as in the resource fork. You may use this flag to create movie files that are more easily moved to other computer systems from your Macintosh.
-
flattenDontInterleaveFlatten
-
Allows you to disable the Movie Toolbox's data storage optimizations. By default, the Movie Toolbox stores movie data in a format that is optimized for playback. Set this flag to 1 to disable these optimizations.
-
flattenActiveTracksOnly
-
Causes the Movie Toolbox to add only enabled movie tracks to the new movie file. You can use the
SetTrackEnabled
function, described on
SetTrackEnabled
, to enable and disable movie tracks.
-
theFile
-
Contains a pointer to the file system specification for the movie file to be created.
-
creator
-
Specifies the creator value for the new file.
-
scriptTag
-
Specifies the script in which the movie file should be created. Set this parameter to the Script Manager constant
smSystemScript
to use the system script; set it to
smCurrentScript
to use the current script. See
Inside Macintosh: Text
for more information about scripts and script tags.
-
createMovieFileFlags
-
Controls file creation options. The following flag is available:
-
createMovieFileDeleteCurFile
-
Indicates whether to delete an existing file. If you set this flag to 1, the Movie Toolbox deletes the file (if it exists) before creating the new movie file. If this flag is set to 0 and the file specified by the
fileSpec
parameter already exists, the Movie Toolbox uses the existing file. In this case, the toolbox ensures that the file has both a data and a resource fork. If this flag is not set, the data is appended to the file.
-
resId
-
Contains a pointer to a field that contains the resource ID number for the new resource. If the field referred to by the
resId
parameter is set to 0, the Movie Toolbox assigns a unique resource ID number to the new resource. The toolbox then returns the movie's resource ID number in the field referred to by the
resId
parameter. The Movie Toolbox assigns resource ID numbers sequentially, starting at 128. If the
resId
parameter is set to
nil
, the Movie Toolbox assigns a unique resource ID number to the new resource and does not return that resource's ID value.
-
resName
-
Points to a character string with the name of the movie resource. If you set the
resName
parameter to
nil
, the toolbox creates an unnamed resource.
DESCRIPTION
The toolbox places the movie resource into the resource fork of the movie file. The Movie Toolbox does not alter the source movie.
The Movie Toolbox calls your progress function during long operations.
ERROR CODES
invalidMovie
|
-2010
|
This movie is corrupted or invalid
|
progressProcAborted
|
-2019
|
Your progress function returned an error
|
cantCreateSingleForkFile
|
-2022
|
Error trying to create a single-fork file
|
File Manager errors Memory Manager errors Resource Manager errors
FlattenMovieData
The
FlattenMovieData
function creates a new movie file and creates a new movie that contains all of its movie data. However, unlike the
FlattenMovie
function described in the previous section, this function does not add the new movie resource to the new movie file. Instead, the
FlattenMovieData
function returns the new movie to your application. Your application must dispose of the returned movie.
pascal Movie FlattenMovieData (Movie theMovie,
long movieFlattenFlags,
const FSSpec *theFile,
OSType creator,
ScriptCode scriptTag,
long createMovieFileFlags);
-
theMovie
-
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
(described on
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
, respectively).
-
movieFlattenFlags
-
Controls the process of adding movie data to the new movie file. These flags affect how the toolbox adds movies to the new movie file later. The following flags are available (be sure to set unused flags to 0):
-
flattenAddMovieToDataFork
-
Causes the movie to be placed in the data fork of the new movie file. You may use this flag to create single-fork movie files, which can be more easily moved to other computer systems from your Macintosh.
-
flattenDontInterleaveFlatten
-
Allows you to disable the Movie Toolbox's data storage optimizations. By default, the Movie Toolbox stores movie data in a format that is optimized for the storage device. Set this flag to 1 to disable these optimizations.
-
flattenActiveTracksOnly
-
Causes the Movie Toolbox to add only enabled movie tracks to the new movie file. You can use the
SetTrackEnabled
function, which is described on
SetTrackEnabled
, to enable and disable movie tracks.
-
theFile
-
Contains a pointer to the file system specification for the movie file to be created.
-
creator
-
Specifies the creator value for the new file.
-
scriptTag
-
Specifies the script in which the movie file should be created. Set this parameter to
smSystemScript
to use the system script; set it to
smCurrentScript
to use the current script. See
Inside Macintosh: Text
for more information about scripts and script tags.
-
creationFlags
-
Controls file creation options. The following flag is available:
-
createMovieFileDeleteCurFile
-
Indicates whether to delete an existing file. If you set this flag to 1, the Movie Toolbox deletes the file (if it exists) before creating the new movie file. If this flag is set to 0 and the file specified by the
fileSpec
parameter already exists, the Movie Toolbox uses the existing file. In this case, the toolbox ensures that the file has both a data and a resource fork. If this flag isn't set, the data is appended to the file.
DESCRIPTION
The
FlattenMovieData
function returns the movie identifier of the new movie. If the function could not create the movie, it sets this returned identifier to
nil
.
You can also use this function to create a single-fork movie file. Set the
flattenAddMovieToDataFork
flag in the
movieFlattenFlags
parameter to 1. The Movie Toolbox then places the movie into the data fork of the movie file.
The Movie Toolbox calls your progress function during long operations.
The Movie Toolbox does not alter the source movie.
ERROR CODES
invalidMovie
|
-2010
|
This movie is corrupted or invalid
|
progressProcAborted
|
-2019
|
Your progress function returned an error
|
cantCreateSingleForkFile
|
-2022
|
Error trying to create a single-fork file
|
File Manager errors Memory Manager errors
NewMovieFromDataFork
The
NewMovieFromDataFork
function enables you to retrieve a movie that is stored anywhere in the data fork of a specified file.
pascal OSErr NewMovieFromDataFork (Movie *theMovie,
short fRefNum,
long fileOffset,
short newMovieFlags,
Boolean *dataRefWasChanged);
-
theMovie
-
Contains a pointer to the movie identifier for the movie to be retrieved. Your application obtains this movie identifier from such functions as
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
(described on
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
, respectively).
-
fRefNum
-
Contains a file reference number to a file that is already open.
-
fileOffset
-
Specifies the starting file offset of the atom in the data fork of the file specified by the
fRefNum
parameter.
-
newMovieFlags
-
Contains the standard flags in the
newMovie
enumeration.
-
newMovieActive
-
Controls whether the new movie is active. Set this flag to 1 to make the new movie active. A movie that does not have any tracks can still be active. When the Movie Toolbox tries to play the movie, no images are displayed, because there is no movie data. You can make a movie active or inactive by calling the
SetMovieActive
function, which is described on
SetMovieActive
.
-
newMovieDontAutoAlternate
-
Controls whether the Movie Toolbox automatically selects enabled tracks from alternate track groups. If you set this flag to 1, the Movie Toolbox does not automatically select tracks for the movie--you must enable tracks yourself.
-
newMovieDontResolveDataRefs
-
Controls how completely the Movie Toolbox resolves data references in the movie resource. If you set this flag to 0, the toolbox tries to completely resolve all data references in the resource. This may involve searching for files on remote volumes. If you set this flag to 1, the Movie Toolbox only looks in the specified file.
-
If the Movie Toolbox cannot completely resolve all the data references, it still returns a valid movie identifier. In this case, the Movie Toolbox also sets the current error value to
couldNotResolveDataRef
.
-
newMovieDontAskUnresolvedDataRefs
-
Controls whether the Movie Toolbox asks the user to locate files. If you set this flag to 0, the Movie Toolbox asks the user to locate files that it cannot find on available volumes. If the Movie Toolbox cannot locate a file even with the user's help, the function returns a valid movie identifier and sets the current error value to
couldNotResolveDataRef
.
-
dataRefWasChanged
-
Contains a pointer to a Boolean value. The Movie Toolbox sets the Boolean to indicate whether it had to change any data references while resolving them. The toolbox sets the Boolean value to
true
if any references were changed. Use the
UpdateMovieResource
function (described on
UpdateMovieResource
) to preserve these changes.
-
Set the
dataRefWasChanged
parameter to
nil
if you do not want to receive this information. See the
"Creating Tracks and Media Structures,"
for more information about data references.
ERROR CODES
badImageDescription
|
-2001
|
Problem with an image description
|
badPublicMovieAtom
|
-2002
|
Movie file corrupted
|
cantFindHandler
|
-2003
|
Cannot locate a handler
|
cantOpenHandler
|
-2004
|
Cannot open a handler
|
File Manager errors Memory Manager errors
PutMovieIntoDataFork
The
PutMovieIntoDataFork
function allows you to store a movie in the data fork of a given file.
pascal OSErr PutMovieIntoDataFork (Movie theMovie, short fRefNum,
long offset, long maxSize);
-
theMovie
-
Identifies the movie to be stored in the data fork of an atom. Your application obtains this movie identifier from such functions as
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
(described on
NewMovie
,
NewMovieFromFile
, and
NewMovieFromHandle
, respectively).
-
fRefNum
-
Contains a file reference number for the data fork of the given file. You pass in an open write path in the
fRefNum
parameter.
-
offset
-
Indicates where the movie should be written.
-
maxSize
-
Indicates the largest number of bytes that may be written.
DESCRIPTION
If necessary, the file will be extended. If there is insufficient space to write the movie, either due to a lack of disk space or because of the limit specified in the
maxSize
parameter, this function returns a
dskFullErr
error code. If there is no limit on how much space the movie may take up in the file, pass 0 in the
maxSize
parameter.
ERROR CODES
invalidMovie
|
-2010
|
This movie is corrupted or invalid
|
Memory Manager errors File Manager errors
© 1997 Apple Computer, Inc.Previous | Chapter Top | Chapter Contents | Next